import { ElOption, } from 'element-plus';
import PrefixLabelSelectV2 from '/@/views/workflow/bpmn/prefix-label-select-v2';
import { ModdleElement } from '../../type';
import { systemApi } from '/@/api/sys/system-api'
import { storeToRefs } from 'pinia';
import { useUserInfo } from '/@/stores/userInfo'
import {
  CommonGroupProperties,
  ExtensionGroupProperties,
  DocumentGroupProperties,
  getElementTypeListenerProperties,
} from '../common';
import { BpmnStore } from '../../store';

const TENANT_ID_OPTIONS:Array<any> = [];
await systemApi.getTenantSelect().then(data => {
  if (data && data.code === 0) {
    data.data.forEach(function (item:any) {
      const x = {label: item.value, value: item.key}
      TENANT_ID_OPTIONS.push(x)
    })
  }
})
const TenantIdOption: JSX.Element = (
  <>
    {TENANT_ID_OPTIONS.map((item) => {
      return <ElOption {...item} />;
    })}
  </>
);
const { userInfos } = storeToRefs(useUserInfo())
// const bpmnContext = BpmnStore
// console.log(bpmnContext.getState().businessObject, 'bpmnContext')
let tenantIdValue = userInfos.value.tenantId
const BaseProcessProperties = {
  ...CommonGroupProperties,
  properties: {
    ...CommonGroupProperties.properties,
    tenantId: {
      component: PrefixLabelSelectV2,
      prefixTitle: '租户',
      disabled: !(import.meta.env.VITE_IS_TENANT && userInfos.value.tenantId === '1'),
      modelValue: tenantIdValue,
      filterable: true,
      options: TENANT_ID_OPTIONS,
    },
  },
};
//流程数据属性配置数组
const ProcessGroupPropertiesArray = [
  BaseProcessProperties,
  /**
   * 监听器组
   */
  getElementTypeListenerProperties({
    name: '全局监听器',
  }),
  ExtensionGroupProperties,
  DocumentGroupProperties,
];

export default {
  //流程
  'bpmn:Process': ProcessGroupPropertiesArray,
  //子流程
  'bpmn:SubProcess': ProcessGroupPropertiesArray,
};
